<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>hsm-statechart: hsm/hsm_state.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="hsm-statechart.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">hsm-statechart
   &#160;<span id="projectnumber">0.5</span>
   </div>
   <div id="projectbrief">An easy to use hierarchical state machine for C and C++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('hsm__state_8h.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">hsm_state.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="hsm__state_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#ifndef __HSM_STATE_H__</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define __HSM_STATE_H__</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="hsm__forwards_8h.html" title="Unwind dependencies b/t hsm header definitions in a friendly way.">hsm_forwards.h</a>&quot;</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#ae16cf40ef01c5e281d2fcb8bba8ac661">   32</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="hsm__forwards_8h.html#aaf8612f2e29f91153ebf2c076aa68030" title="Pointer to an hsm_state_rec.">hsm_state</a>(*<a class="code" href="hsm__state_8h.html#ae16cf40ef01c5e281d2fcb8bba8ac661" title="A state&#39;s event handler callback.">hsm_callback_process_event</a>)( <a class="code" href="hsm__status_8h.html#structhsm__status__rec" title="Structure used for consolidating callback parameters.">hsm_status</a> status );</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div>
<div class="line"><a name="l00052"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#af766d6e8715b04f423b490cc5a056bf1">   52</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="hsm__forwards_8h.html#aa0e37ff043d2dd5216cc762ca03046cb" title="Pointer to an hsm_context_rec.">hsm_context</a> (*<a class="code" href="hsm__state_8h.html#af766d6e8715b04f423b490cc5a056bf1" title="A state&#39;s enter callback.">hsm_callback_enter</a>)( <a class="code" href="hsm__status_8h.html#structhsm__status__rec" title="Structure used for consolidating callback parameters.">hsm_status</a> status );</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;</div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#a5a740484248abeee497979cbac897ac8">   60</a></span>&#160;<span class="keyword">typedef</span> void(*<a class="code" href="hsm__state_8h.html#a5a740484248abeee497979cbac897ac8" title="A state&#39;s action callback.">hsm_callback_action</a>)( <a class="code" href="hsm__status_8h.html#structhsm__status__rec" title="Structure used for consolidating callback parameters.">hsm_status</a> status );</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#a75bddc6c285b72e7c14b011150df5ef8">   68</a></span>&#160;<span class="keyword">typedef</span> hsm_bool(*<a class="code" href="hsm__state_8h.html#a75bddc6c285b72e7c14b011150df5ef8" title="Guard callback.">hsm_callback_guard</a>)( <a class="code" href="hsm__status_8h.html#structhsm__status__rec" title="Structure used for consolidating callback parameters.">hsm_status</a> status);</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;</div>
<div class="line"><a name="l00075"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#af4d0dd11f8eb4db16255bd0566e92ba4">   75</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="hsm__state_8h.html#a5a740484248abeee497979cbac897ac8" title="A state&#39;s action callback.">hsm_callback_action</a> <a class="code" href="hsm__state_8h.html#af4d0dd11f8eb4db16255bd0566e92ba4" title="A state&#39;s exit callback.">hsm_callback_exit</a>;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="hsm__state_8h.html#structhsm__state__rec" title="a state descriptor http://dev.ionous.net/2012/06/state-descriptors.html">hsm_state_rec</a> <a class="code" href="hsm__state_8h.html#structhsm__state__rec" title="a state descriptor http://dev.ionous.net/2012/06/state-descriptors.html">hsm_state_t</a>;</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;<span class="comment">//---------------------------------------------------------------------------</span></div>
<div class="line"><a name="l00085"></a><span class="lineno"><a class="code" href="hsm__state_8h.html">   85</a></span>&#160;<span class="comment"></span><span class="keyword">struct </span><a class="code" href="hsm__state_8h.html#structhsm__state__rec" title="a state descriptor http://dev.ionous.net/2012/06/state-descriptors.html">hsm_state_rec</a></div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;{</div>
<div class="line"><a name="l00090"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#a8f8f80d37794cde9472343e4487ba3eb">   90</a></span>&#160;    <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="hsm__state_8h.html#a8f8f80d37794cde9472343e4487ba3eb" title="name of the state ( useful for debugging )">name</a>;</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;</div>
<div class="line"><a name="l00095"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#a33029b0d2695fe40010884b199bd7546">   95</a></span>&#160;    <a class="code" href="hsm__state_8h.html#ae16cf40ef01c5e281d2fcb8bba8ac661" title="A state&#39;s event handler callback.">hsm_callback_process_event</a> <a class="code" href="hsm__state_8h.html#a33029b0d2695fe40010884b199bd7546" title="the state&#39;s event handler callback">process</a>;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    </div>
<div class="line"><a name="l00100"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#aa6a1c3b1e97b0015afee5573fb3ddc78">  100</a></span>&#160;    <a class="code" href="hsm__state_8h.html#af766d6e8715b04f423b490cc5a056bf1" title="A state&#39;s enter callback.">hsm_callback_enter</a> <a class="code" href="hsm__state_8h.html#aa6a1c3b1e97b0015afee5573fb3ddc78" title="enter action handler">enter</a>; </div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;</div>
<div class="line"><a name="l00105"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#af28bc68a562cca87d34f862c6ba6d3d6">  105</a></span>&#160;    <a class="code" href="hsm__state_8h.html#af4d0dd11f8eb4db16255bd0566e92ba4" title="A state&#39;s exit callback.">hsm_callback_exit</a> <a class="code" href="hsm__state_8h.html#af28bc68a562cca87d34f862c6ba6d3d6" title="exit action handler">exit</a>;</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;</div>
<div class="line"><a name="l00110"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#a74ac4b1f244bc97ba0c1daab6f76979b">  110</a></span>&#160;    <a class="code" href="hsm__state_8h.html#structhsm__state__rec" title="a state descriptor http://dev.ionous.net/2012/06/state-descriptors.html">hsm_state</a> <a class="code" href="hsm__state_8h.html#a74ac4b1f244bc97ba0c1daab6f76979b" title="default sub-state (if any) for this state">initial</a>;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;</div>
<div class="line"><a name="l00115"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#aa4980a3eab7184813f0cd0a98a201fcb">  115</a></span>&#160;    <a class="code" href="hsm__state_8h.html#structhsm__state__rec" title="a state descriptor http://dev.ionous.net/2012/06/state-descriptors.html">hsm_state</a> <a class="code" href="hsm__state_8h.html#aa4980a3eab7184813f0cd0a98a201fcb" title="parent of this state">parent</a>;</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;</div>
<div class="line"><a name="l00122"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#acb5ba97551079e0b072c62c21d784ac5">  122</a></span>&#160;    <span class="keywordtype">int</span> <a class="code" href="hsm__state_8h.html#acb5ba97551079e0b072c62c21d784ac5" title="distance to the root state this-&gt;depth = this-&gt;parent-&gt;depth+1; root most state&#39;s depth == 0...">depth</a>;</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;};</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;</div>
<div class="line"><a name="l00139"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#a13ea60f370fd7663153ad6d7fb7c73e1">  139</a></span>&#160;<span class="preprocessor">#define HSM_STATE( state, parent, initial ) \</span></div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;<span class="preprocessor">        hsm_state state##Event( hsm_status ); \</span></div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;<span class="preprocessor">        _HSM_STATE( state, parent, state##Event, 0, 0, initial )</span></div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00156"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#a0cb7e4f750bdd83a03d75df4714f2efa">  156</a></span>&#160;<span class="preprocessor">#define HSM_STATE_ENTER( state, parent, initial ) \</span></div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;<span class="preprocessor">        hsm_state state##Event( hsm_status ); \</span></div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;<span class="preprocessor">        hsm_context state##Enter( hsm_status ); \</span></div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;<span class="preprocessor">        _HSM_STATE( state, parent, state##Event, state##Enter, 0, initial );</span></div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00175"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#a3263608681f4ec0b1075cb3c9c0a9280">  175</a></span>&#160;<span class="preprocessor">#define HSM_STATE_ENTERX( state, parent, initial ) \</span></div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;<span class="preprocessor">        hsm_state state##Event( hsm_status ); \</span></div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;<span class="preprocessor">        hsm_context state##Enter( hsm_status ); \</span></div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;<span class="preprocessor">        void state##Exit ( hsm_status ); \</span></div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;<span class="preprocessor">        _HSM_STATE( state, parent, state##Event, state##Enter, state##Exit, initial );</span></div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00193"></a><span class="lineno"><a class="code" href="hsm__state_8h.html#af67fed27704933cb81dffe693588cb14">  193</a></span>&#160;<span class="preprocessor">#define _HSM_STATE( State, Parent, Process, Enter, Exit, Initial ) \</span></div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;<span class="preprocessor">        hsm_state Parent(); \</span></div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;<span class="preprocessor">        hsm_state State##Lookup##Initial(); \</span></div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;<span class="preprocessor">        hsm_state State##Lookup##0() { return 0; } \</span></div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;<span class="preprocessor">        hsm_state State() { \</span></div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;<span class="preprocessor">            static struct hsm_state_rec myinfo= { 0 }; \</span></div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;<span class="preprocessor">            if (!myinfo.name) { \</span></div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;<span class="preprocessor">                myinfo.name= #State; \</span></div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;<span class="preprocessor">                myinfo.process= Process; \</span></div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;<span class="preprocessor">                myinfo.enter= Enter; \</span></div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;<span class="preprocessor">                myinfo.exit= Exit; \</span></div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;<span class="preprocessor">                myinfo.parent= Parent(); \</span></div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;<span class="preprocessor">                myinfo.depth= myinfo.parent ? myinfo.parent-&gt;depth+1 : 0; \</span></div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;<span class="preprocessor">                myinfo.initial= State##Lookup##Initial(); \</span></div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;<span class="preprocessor">            } \</span></div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;<span class="preprocessor">            return &amp;myinfo; \</span></div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;<span class="preprocessor">        } \</span></div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;<span class="preprocessor">        hsm_state Parent##Lookup##State() { return State(); }</span></div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;<span class="preprocessor"></span> </div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;<span class="preprocessor">#endif // #ifndef __HSM_STATE_H__</span></div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;<span class="preprocessor"></span></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_6c36b64852547327283732128225c9d7.html">hsm</a></li><li class="navelem"><a class="el" href="hsm__state_8h.html">hsm_state.h</a></li>
    <li class="footer">Generated on Sat Jul 7 2012 22:48:11 for hsm-statechart by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.1.1 </li>
  </ul>
</div>
</body>
</html>
